<template>
  <div class="index">
    <div class="title">
      <div class="block"></div>
      <div class="word">
        系统首页
      </div>
      <div class="button">
        <el-button class="el-button" @click="refresh">刷新</el-button>
      </div>
    </div>
    <div class="content">
      <div class="views">
        <div class="total-order">
          <img class="icon"
               src="../../../assets/index/total-order.svg"
               alt="" />
          <div style="margin-left: 10px;margin-top: 20px">
            <div style="color: #999999">
              今日订单总数
            </div>
            <div style="margin-top: 5px">
              {{todaytotalorder}}
            </div>
          </div>
        </div>
        <div class="total-amount">
          <img class="icon"
               src="../../../assets/index/total-amount.svg"
               alt="" />
          <div style="margin-left: 10px;margin-top: 20px">
            <div style="color: #999999">
              今日订单总额
            </div>
            <div style="margin-top: 5px">
              ¥{{todaytotalorderamount}}
            </div>
          </div>
        </div>
        <div class="yesturday-amount">
          <img class="icon"
               src="../../../assets/index/yesturday-amount.svg"
               alt="" />
          <div style="margin-left: 10px;margin-top: 20px">
            <div style="color: #999999">
              昨日订单总额
            </div>
            <div style="margin-top: 5px">
              ¥{{yesturdaytotalorderamount}}
            </div>
          </div>
        </div>
        <div class="last-sevendays">
          <img class="icon"
               src="../../../assets/index/last-sevendays.svg"
               alt="" />
          <div style="margin-left: 10px;margin-top: 20px">
            <div style="color: #999999">
              近7天订单总额
            </div>
            <div style="margin-top: 5px">
              ¥{{totalamount}}
            </div>
          </div>
        </div>
      </div>
      <div class="affair">
        <div class="affair-title">待处理事务</div>
        <div class="affair-details">
          <div class="item">
            <span @click="getDepositList">待支付押金订单</span>
            <span>(<span class="affair-total">{{deposittopay}}</span>)</span>
          </div>
          <div class="item">
            <span @click="getBaseInfoList">基本资料订单</span><span>(<span class="affair-total">{{baseinfo}}</span>)</span>
          </div>
          <div class="item">
            <span @click="getWaitTextList">待文书确认订单</span><span>(<span class="affair-total">{{confirmorder}}</span>)</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getAllCount,
  getTodayTotalOrder,
  getYesturdayTotalOrder,
  getDepositToPay,
  getBaseInfo,
  getConfirmOrder
} from '../../../api/index'
export default {
  inject: ['reload'],
  name: 'index',
  components: {},
  data () {
    return {
      todaytotalorder: '',//今日订单总数
      todaytotalorderamount: '',//今日订单总额
      yesturdaytotalorderamount: '',//昨日订单总额
      totalamount: '',//近7天订单总额
      deposittopay: '',//待处理事务数
      baseinfo: '',//基本资料订单
      confirmorder: '',//确认订单
    }
  },
  methods: {
    refresh() {
      this.reload()
    },
    //待押金支付
    getDepositList() {
      this.$router.push({
        name: "overseasList",
        params: {
          statusName: '待支付押金',
        },
      });
    },
    //待审核基本资料
    getBaseInfoList() {
      this.$router.push({
        name: "overseasList",
        params: {
          statusName: '基本资料',
        },
      });
    },
    //待文书确认订单
    getWaitTextList() {
      this.$router.push({
        name: "overseasList",
        params: {
          statusName: '待文书确认',
        },
      });
    }

  },
  mounted () {
    this.$emit('routeName', "index");
    //  发送请求获取数据
    getAllCount().then(data => {
      this.totalamount = data.data.amount
    });
    getTodayTotalOrder().then(data => {
      this.todaytotalorder = data.data.total
      this.todaytotalorderamount = data.data.amount
    });
    getYesturdayTotalOrder().then(data => {
      this.yesturdaytotalorderamount = data.data.amount
    });
    getDepositToPay().then(data => {
      this.deposittopay = data.data
    });
    getBaseInfo().then(data => {
      this.baseinfo = data.data
    });
    getConfirmOrder().then(data => {
      this.confirmorder = data.data
    });
  }
}
</script>

<style scoped>
.title {
  position: relative;
  display: flex;
  width: 100%;
  height: 50px;
  border-bottom: 1px solid #e4e4e4;
  line-height: 50px;
  background-color: #f3f3f3;
}
.block {
  width: 5px;
  height: 30px;
  margin-top: 10px;
  margin-left: 5px;
  background-color: #1abc9c;
}
/* 标题文字 */
.word {
  width: 100px;
  margin-left: 5px;
  color: #999999;
}
.button {
  position: absolute;
  right: 30px;
}
.views {
  width: 100%;
  margin-top: 10px;
  display: flex;
  justify-content: space-around;
}
.total-order,
.total-amount,
.yesturday-amount,
.last-sevendays {
  width: 300px;
  height: 100px;
  display: flex;
  border: 1px solid #e4e4e4;
  background-color: white;
}
/* 顶部四个小图标 */
.icon {
  width: 50px;
  height: 50px;
  padding-top: 20px;
  padding-left: 20px;
}
.affair {
  width: 98%;
  height: 200px;
  /* height: auto; */
  margin-top: 20px;
  margin-left: 15px;
  margin-right: 150px;
  border: 1px solid #e4e4e4;
  background-color: white;
}
.affair-title {
  padding-left: 20px;
  width: 100%;
  height: 50px;
  line-height: 50px;
  color: #666666;
  font-size: 15px;
  font-weight: 600;
  background-color: #f3f3f3;
}
.item {
  display: flex;
  width: 200px;
  padding: 0 30px;
  justify-content: space-between;
  cursor: pointer;
}
.affair-details {
  width: 100%;
  display: flex;
  justify-content: space-around;
}
.affair-details div {
  width: 400px;
  height: 50px;
  line-height: 50px;
  color: #666666;
  border-bottom: 1px solid #f2f2f2;
}
.affair-details span:hover {
  color: #1ac2c6;
}
.affair-total {
  color: red;
}
.affair-total:hover {
  color: #1ac2c6;
}
</style>
